// pages/teacher/mine/classCourse/classCourse.js
var app = getApp();
import {teacher_active} from "../../../../asserts/js/common/barList";
import {initCourseInit, getCourseParam} from "../../../../asserts/js/common/shareFun";
import {post} from "../../../../asserts/js/request";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    barList: teacher_active(1),
    top: app.globalData.bottom + 'px',
    course_list: [
      {
        src: "/asserts/imgs/temp/course.jpeg",
        time: "2020-01-01 09:01:00",
        stu: "1.0万人已学习",
        info: "world of dance 比赛舞曲快速入门",
        id:"1"
      },
      {
        src: "/asserts/imgs/temp/course.jpeg",
        time: "2020-01-01 09:01:00",
        stu: "1.1万人已学习",
        info: "world of dance 比赛舞曲快速入门",
        id:"2"
      },
      {
        src: "/asserts/imgs/temp/course.jpeg",
        time: "2020-01-01 09:01:00",
        stu: "1.1万人已学习",
        info: "world of dance 比赛舞曲快速入门",
        id:"3"
      },
      {
        src: "/asserts/imgs/temp/course.jpeg",
        time: "2020-01-01 09:01:00",
        stu: "1.1万人已学习",
        info: "world of dance 比赛舞曲快速入门",
        id:"4"
      }
    ],
    tabObj: {},
    alter_show: false,
    buttom_title: {
      title1: '舞种',
      title2: "课程类型"
    },
    danceKind: [],
    courseLevel: [],
    courseNature: [],
    courseKind:[],
    className: '',
    classId: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var obj = initCourseInit(app.globalData.enum_courseTypes, app.globalData.enum_courseKinds, app.globalData.enum_courseNature)
    this.setData({
      tabObj: obj,
      classId: options.classId
    });
    this.getData();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  selectBoxShow: function(){
    this.setData({
      alter_show: true
    })
  },
  alterCancel: function() {
    this.setData({
      alter_show: false
    })
  },
  back: function() {
    wx.navigateBack({
      delta: 0,
    })
  },
  itemCLick: function(e) {
    var obj = new Object();
    obj.code = "homeworkDetail";
    obj.oriData = e.currentTarget.dataset.item;
    console.log(obj)
    wx.setStorageSync('classItem', obj);
    wx.navigateTo({
      url: '/pages/teacher/mine/homeworkDetail/homeworkDetail?classId='+ this.data.classId,
    })
  },
  selectSure: function(e) {
    let this_ = this;
    var paramList = getCourseParam(e.detail.tabList);
    this.setData({
      danceKind: paramList.danceKind,
      courseLevel: paramList.courseLevel,
      courseNature: paramList.courseNature,
      alter_show: false
    }, function(){
      this_.getData()
    })
  },
  nameChange: function(e) {
    this.setData({
      className: e.detail.value
    })
  },
  getData: function() {
    let this_ = this;
    post("queryMyClassDetail", {
      classId: this.data.classId,
      danceKind: this.data.danceKind.join("|"),
  //  courseLevel: this.data.courseLevel.join("|"),
      courseKind: this.data.courseLevel.join("|"),
      courseNature: this.data.courseNature.join("|"),
      className: this.data.className
    }).then(data => {
      this_.setData({
        course_list: data.courseInfo
      })
    })
  }

})